﻿using System;
using UnityEngine;

// Token: 0x02000152 RID: 338
[RequireComponent(typeof(DriveForce))]
public abstract class Transmission : MonoBehaviour
{
	// Token: 0x06000612 RID: 1554 RVA: 0x00031F22 File Offset: 0x00030122
	public virtual void Start()
	{
		this.vp = (VehicleParent)F.GetTopmostParentComponent<VehicleParent>(base.transform);
		this.targetDrive = base.GetComponent<DriveForce>();
		this.newDrive = base.gameObject.AddComponent<DriveForce>();
	}

	// Token: 0x06000613 RID: 1555 RVA: 0x00031F58 File Offset: 0x00030158
	protected void SetOutputDrives(float ratio)
	{
		if (this.outputDrives.Length > 0)
		{
			int num = 0;
			foreach (DriveForce driveForce in this.outputDrives)
			{
				if (driveForce.active)
				{
					num++;
				}
			}
			float torqueFactor = Mathf.Pow(1f / (float)num, this.driveDividePower);
			float num2 = 0f;
			foreach (DriveForce driveForce2 in this.outputDrives)
			{
				if (driveForce2.active)
				{
					num2 += ((!this.skidSteerDrive) ? driveForce2.feedbackRPM : Mathf.Abs(driveForce2.feedbackRPM));
					driveForce2.SetDrive(this.newDrive, torqueFactor);
				}
			}
			this.targetDrive.feedbackRPM = num2 / (float)num * ratio;
		}
	}

	// Token: 0x06000614 RID: 1556 RVA: 0x0003203C File Offset: 0x0003023C
	public void ResetMaxRPM()
	{
		this.maxRPM = -1f;
	}

	// Token: 0x04000967 RID: 2407
	[Range(0f, 1f)]
	public float strength = 1f;

	// Token: 0x04000968 RID: 2408
	[NonSerialized]
	public float health = 1f;

	// Token: 0x04000969 RID: 2409
	protected VehicleParent vp;

	// Token: 0x0400096A RID: 2410
	protected DriveForce targetDrive;

	// Token: 0x0400096B RID: 2411
	protected DriveForce newDrive;

	// Token: 0x0400096C RID: 2412
	public bool automatic;

	// Token: 0x0400096D RID: 2413
	[Tooltip("Apply special drive to wheels for skid steering")]
	public bool skidSteerDrive;

	// Token: 0x0400096E RID: 2414
	public DriveForce[] outputDrives;

	// Token: 0x0400096F RID: 2415
	[Tooltip("Exponent for torque output on each wheel")]
	public float driveDividePower = 3f;

	// Token: 0x04000970 RID: 2416
	[NonSerialized]
	public float maxRPM = -1f;
}
